<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>nandps: xnandps_cache_example.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">nandps
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="pages.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xnandps__cache__example_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">xnandps_cache_example.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file contains a design example using the NAND driver (XNandPs). </p>
<p>This example tests NAND page cache read and write commands. The page cache commands are not supported by OnDie ECC flash since ECC is enabled by default. Tested Spansion S34ML04G100TFI00 flash with this example.</p>
<p>This example tests the block erase, block read and block write features. The flash blocks are erased and written. The data is read back and compared with the data written for correctness. The bad blocks are not erased/programmed.</p>
<dl class="section note"><dt>Note</dt><dd></dd></dl>
<p>None.</p>
<pre>
 MODIFICATION HISTORY:</pre><pre> Ver   Who  Date        Changes
</p>
<hr/>
<p>
 1.00  nm   04/25/2013  First release.
       ms   04/10/17    Modified Comment lines to follow doxygen rules
 2.8  akm   07/06/23    Add support for system device-tree flow.
</pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a7db05d815b66eacb631170259b85d4e0"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xnandps__cache__example_8c.html#a7db05d815b66eacb631170259b85d4e0">NAND_TEST_START_BLOCK</a>&#160;&#160;&#160;64</td></tr>
<tr class="memdesc:a7db05d815b66eacb631170259b85d4e0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Starting block to test.  <a href="#a7db05d815b66eacb631170259b85d4e0">More...</a><br/></td></tr>
<tr class="separator:a7db05d815b66eacb631170259b85d4e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af16e18758ac741c6c92311ae783d41a0"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xnandps__cache__example_8c.html#af16e18758ac741c6c92311ae783d41a0">NAND_TEST_NUM_BLOCKS</a>&#160;&#160;&#160;16</td></tr>
<tr class="memdesc:af16e18758ac741c6c92311ae783d41a0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of blocks to test.  <a href="#af16e18758ac741c6c92311ae783d41a0">More...</a><br/></td></tr>
<tr class="separator:af16e18758ac741c6c92311ae783d41a0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aceb54e188b945273e687c4972994d58b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xnandps__cache__example_8c.html#aceb54e188b945273e687c4972994d58b">NAND_TEST_BLOCK_SIZE</a>&#160;&#160;&#160;0x20000</td></tr>
<tr class="memdesc:aceb54e188b945273e687c4972994d58b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Test Block Size, must be same as the flash block size.  <a href="#aceb54e188b945273e687c4972994d58b">More...</a><br/></td></tr>
<tr class="separator:aceb54e188b945273e687c4972994d58b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:aa1f7a7e02cb31d5fbe75d5f33b5ae4dc"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xnandps__cache__example_8c.html#aa1f7a7e02cb31d5fbe75d5f33b5ae4dc">NandReadWriteCacheExample</a> (u32 NandDeviceId)</td></tr>
<tr class="memdesc:aa1f7a7e02cb31d5fbe75d5f33b5ae4dc"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function runs a test on the NAND flash device using the basic driver functions.  <a href="#aa1f7a7e02cb31d5fbe75d5f33b5ae4dc">More...</a><br/></td></tr>
<tr class="separator:aa1f7a7e02cb31d5fbe75d5f33b5ae4dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a840291bc02cba5474a4cb46a9b9566fe"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xnandps__cache__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
<tr class="memdesc:a840291bc02cba5474a4cb46a9b9566fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function to execute the Nand Flash read write example.  <a href="#a840291bc02cba5474a4cb46a9b9566fe">More...</a><br/></td></tr>
<tr class="separator:a840291bc02cba5474a4cb46a9b9566fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:aaa747f224cb3f776fb6ecafded15e090"><td class="memItemLeft" align="right" valign="top">u8&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xnandps__cache__example_8c.html#aaa747f224cb3f776fb6ecafded15e090">ReadBuffer</a> [<a class="el" href="xnandps__example_8c.html#aceb54e188b945273e687c4972994d58b">NAND_TEST_BLOCK_SIZE</a>]</td></tr>
<tr class="memdesc:aaa747f224cb3f776fb6ecafded15e090"><td class="mdescLeft">&#160;</td><td class="mdescRight">Block sized Read buffer.  <a href="#aaa747f224cb3f776fb6ecafded15e090">More...</a><br/></td></tr>
<tr class="separator:aaa747f224cb3f776fb6ecafded15e090"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a61d7712760b0620e08f131bb16df45cd"><td class="memItemLeft" align="right" valign="top">u8&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xnandps__cache__example_8c.html#a61d7712760b0620e08f131bb16df45cd">WriteBuffer</a> [<a class="el" href="xnandps__example_8c.html#aceb54e188b945273e687c4972994d58b">NAND_TEST_BLOCK_SIZE</a>]</td></tr>
<tr class="memdesc:a61d7712760b0620e08f131bb16df45cd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Block sized write buffer.  <a href="#a61d7712760b0620e08f131bb16df45cd">More...</a><br/></td></tr>
<tr class="separator:a61d7712760b0620e08f131bb16df45cd"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="aceb54e188b945273e687c4972994d58b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define NAND_TEST_BLOCK_SIZE&#160;&#160;&#160;0x20000</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Test Block Size, must be same as the flash block size. </p>

<p>Referenced by <a class="el" href="xnandps__cache__example_8c.html#aa1f7a7e02cb31d5fbe75d5f33b5ae4dc">NandReadWriteCacheExample()</a>.</p>

</div>
</div>
<a class="anchor" id="af16e18758ac741c6c92311ae783d41a0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define NAND_TEST_NUM_BLOCKS&#160;&#160;&#160;16</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Number of blocks to test. </p>

<p>Referenced by <a class="el" href="xnandps__cache__example_8c.html#aa1f7a7e02cb31d5fbe75d5f33b5ae4dc">NandReadWriteCacheExample()</a>.</p>

</div>
</div>
<a class="anchor" id="a7db05d815b66eacb631170259b85d4e0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define NAND_TEST_START_BLOCK&#160;&#160;&#160;64</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Starting block to test. </p>

<p>Referenced by <a class="el" href="xnandps__cache__example_8c.html#aa1f7a7e02cb31d5fbe75d5f33b5ae4dc">NandReadWriteCacheExample()</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a840291bc02cba5474a4cb46a9b9566fe"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Main function to execute the Nand Flash read write example. </p>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS if the example has completed successfully.</li>
<li>XST_FAILURE if the example has failed.</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>References <a class="el" href="xnandps__cache__example_8c.html#aa1f7a7e02cb31d5fbe75d5f33b5ae4dc">NandReadWriteCacheExample()</a>.</p>

</div>
</div>
<a class="anchor" id="aa1f7a7e02cb31d5fbe75d5f33b5ae4dc"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int NandReadWriteCacheExample </td>
          <td>(</td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>NandDeviceId</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function runs a test on the NAND flash device using the basic driver functions. </p>
<p>The function does the following tasks:</p>
<ul>
<li>Initialize the driver.</li>
<li>Erase the blocks.</li>
<li>Write in to all the blocks.</li>
<li>Read back the data from the blocks.</li>
<li>Compare the data read against the data Written.</li>
</ul>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">NandDeviceId</td><td>is is the XPAR_&lt;NAND_instance&gt;_DEVICE_ID value from xparameters.h.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS if successful.</li>
<li>XST_FAILURE if failed.</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd>When bad blocks are encountered, they are not erased and programmed. </dd></dl>

<p>References <a class="el" href="struct_x_nand_ps___geometry.html#a27ad012d0279b497f04a927a6632a9ea">XNandPs_Geometry::BlockSize</a>, <a class="el" href="struct_x_nand_ps___config.html#a0a1930e4ef28ad9c5d05e7bebafb14e0">XNandPs_Config::FlashBase</a>, <a class="el" href="struct_x_nand_ps_tag.html#ae87fd6bcc9622ee7d41abdbdaad61c35">XNandPsTag::Geometry</a>, <a class="el" href="xnandps__cache__example_8c.html#aceb54e188b945273e687c4972994d58b">NAND_TEST_BLOCK_SIZE</a>, <a class="el" href="xnandps__cache__example_8c.html#af16e18758ac741c6c92311ae783d41a0">NAND_TEST_NUM_BLOCKS</a>, <a class="el" href="xnandps__cache__example_8c.html#a7db05d815b66eacb631170259b85d4e0">NAND_TEST_START_BLOCK</a>, <a class="el" href="xnandps__cache__example_8c.html#aaa747f224cb3f776fb6ecafded15e090">ReadBuffer</a>, <a class="el" href="struct_x_nand_ps___config.html#a7fb228465433017747bbf8a9bd9601d7">XNandPs_Config::SmcBase</a>, <a class="el" href="xnandps__cache__example_8c.html#a61d7712760b0620e08f131bb16df45cd">WriteBuffer</a>, <a class="el" href="group__nandps.html#gaddb9f847fae34f6d137f591375a7c962">XNandPs_CfgInitialize()</a>, <a class="el" href="group__nandps.html#ga22b4e2bc1af7e4bfecd4428c25a77bb8">XNandPs_EraseBlock()</a>, <a class="el" href="group__nandps.html#ga5744d2e6e03eb2b815771cf660ab2e11">XNandPs_IsBlockBad()</a>, <a class="el" href="group__nandps.html#gad64edb80b795bb18ecceb9428b458903">XNandPs_LookupConfig()</a>, <a class="el" href="group__nandps.html#ga605bd783f065806f1d1f602f88128f9b">XNandPs_ReadCache()</a>, and <a class="el" href="group__nandps.html#ga8ecd5bb0fc73b3011ee0ba500e0161fe">XNandPs_WriteCache()</a>.</p>

<p>Referenced by <a class="el" href="xnandps__cache__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main()</a>.</p>

</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a class="anchor" id="aaa747f224cb3f776fb6ecafded15e090"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u8 ReadBuffer[<a class="el" href="xnandps__example_8c.html#aceb54e188b945273e687c4972994d58b">NAND_TEST_BLOCK_SIZE</a>]</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Block sized Read buffer. </p>

<p>Referenced by <a class="el" href="xnandps__cache__example_8c.html#aa1f7a7e02cb31d5fbe75d5f33b5ae4dc">NandReadWriteCacheExample()</a>, <a class="el" href="xnandps__example_8c.html#a2457ffd11ebf44ab8474e635ec7aaa82">NandReadWriteExample()</a>, and <a class="el" href="xnandps__skip__example_8c.html#a12ce7ac809b89c86c434dd46a0cd51a4">NandSkipBlockExample()</a>.</p>

</div>
</div>
<a class="anchor" id="a61d7712760b0620e08f131bb16df45cd"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u8 WriteBuffer[<a class="el" href="xnandps__example_8c.html#aceb54e188b945273e687c4972994d58b">NAND_TEST_BLOCK_SIZE</a>]</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Block sized write buffer. </p>

<p>Referenced by <a class="el" href="xnandps__cache__example_8c.html#aa1f7a7e02cb31d5fbe75d5f33b5ae4dc">NandReadWriteCacheExample()</a>, <a class="el" href="xnandps__example_8c.html#a2457ffd11ebf44ab8474e635ec7aaa82">NandReadWriteExample()</a>, and <a class="el" href="xnandps__skip__example_8c.html#a12ce7ac809b89c86c434dd46a0cd51a4">NandSkipBlockExample()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
